import React from "react";
import { Menu } from 'antd/lib';
import Enums from "@/services/enums";
import MailOutlined from "@ant-design/icons/MailOutlined";
const { SubMenu } = Menu;

export default class CalendarTree extends React.Component {
  state = {
    subMenus: ['sub2'],     
    current_id: 0,      //第一个日历下的第一个打开期间
  };

  componentWillMount() {
    Enums.items('calendar_enum').then(data => {
      this.setState({
        subMenus: data,
      });
      this.refreshData();
    });
  }

  refreshData() {
    this.setState({
      current_id: 0,
    });
}

  handleClick = e => {
    console.log('click ', e);
  };

  render() {
    return (
      <Menu
        onClick={this.handleClick}
        style={{ width: 256 }}
        defaultSelectedKeys={[this.state.current_id]}
        defaultOpenKeys={[this.state.subMenus[0].value]}
        mode="inline"
      >
      {this.props.is_public && (<Menu.Item key="1">基础查询</Menu.Item>)}
      {this.state.subMenus.map(menu => (
        <SubMenu
        key={menu.value}
        title={
          <span>
            <MailOutlined />
        <span>{menu.label}</span>
          </span>
        }
        >

        </SubMenu>
      ))}
      </Menu>
    );
  }
}

